package bFirma;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class AgendaMain {

	public static void main(String[] args) throws Exception {
		String sql = "select * from agenda";
		String url = "jdbc:oracle:thin:@localhost:1521:xe";
		
		try (Connection con = DriverManager.getConnection(url, "estudoDb", "ricardo");		
				PreparedStatement stm = con.prepareStatement(sql);
				ResultSet rs = stm.executeQuery()){
			
					while(rs.next()){
						System.out.println(rs.getString("id"));
						System.out.println(rs.getString("nomeContato"));
						System.out.println(rs.getString("telContato"));
						}
					
					System.out.println("=================================================");
					
					AgendaCRUD crud = new AgendaCRUD();
					Agenda agenda = new Agenda("Rapouso Tavares", 99842332);
					crud.criar(con, agenda);
					
					while(rs.next()){
						System.out.println(rs.getString("id"));
						System.out.println(rs.getString("nomeContato"));
						System.out.println(rs.getString("telContato"));
						}
				}
		
	}

}
